package converter;

import java.util.ArrayList;
import java.util.List;

public class RevertConverterImpl<D, S extends D> implements
        RevertConverter<D, S> {

    public RevertConverterImpl(Class<S> subClass) {
        this.subClass = subClass;
    }

    @Override
    public List<S> convert(List<D> source) {
        List<S> result = new ArrayList<S>();

        for (D d : source) {
            if (d.getClass().equals(subClass)) {
                result.add( subClass.cast(d));
            }
        }

        return result;
    }
    
    private final Class<S> subClass;

}
